Build a stateless service with all state in external stores, deploy N replicas behind a load balancer, use circuit breakers for downstream dependencies, and design for graceful degradation.
Stateless: all session state, cache, and persistent data lives in Postgres, Redis, or object storage
Connection pooling: pgxpool with MaxConns = (postgres_max_connections / replicas) - buffer
Health checks: /readiness (DB connected, dependencies available) and /liveness (process alive) for Kubernetes
Graceful shutdown: drain in-flight requests before exiting on SIGTERM
Zero-downtime deploy: rolling updates work because the service is stateless and backward-compatible
Horizontal scaling: deploy more replicas — works because service is stateless
Distributed locking: Postgres advisory locks or Redlock for critical sections across replicas
Caching: Redis for session data, hot DB queries, and rate limit counters
Bulkhead: separate goroutine pools for different request types to prevent cascade failures
Retry with exponential backoff and jitter for transient failures in downstream calls